import 'package:flutter/material.dart';
import 'package:get/get.dart';

import '../../../../../service/global_service.dart';
import '../../../../models/user_model.dart';
import 'state.dart';

class VerifyAccountController extends GetxController {
  // 状态
  final VerifyAccountState state = VerifyAccountState();

  // 安全操作类型（默认修改密码）
  SecurityType securityType = SecurityType.resetPwd;

  @override
  void onInit() {
    super.onInit();

    if (Get.arguments != null && Get.arguments is SecurityType) {
      securityType = Get.arguments;
    } else {
      debugPrint(
          "❌ VerifyAccountController: Missing or invalid SecurityType argument");
      Get.back();
    }

    // 赋值是否存在已验证的手机号/邮箱
    state.existPhoneVerification.value =
        GlobalService.to.cacheUserInfo.value.phone.isNotEmpty;
    state.existEmailVerification.value =
        GlobalService.to.cacheUserInfo.value.email.isNotEmpty;
  }
}
